<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
<%@page import="com.liferay.portal.kernel.util.Validator"%>
<%@page import="com.library.LibraryPortlet"%>
<%@page import="com.liferay.portal.kernel.dao.search.SearchContainer"%>
<%@page import="com.slayer.service.LMSBookLocalServiceUtil"%>
<%@page import="com.slayer.model.LMSBook"%>
<%@page import="java.util.List"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@include file="/html/library/init.jsp"%>
<%
ThemeDisplay td = (ThemeDisplay)request.getAttribute("THEME_DISPLAY");	
List<LMSBook> books = (List<LMSBook>)request.getAttribute("SEARCHRESULT");
if(Validator.isNull(books))
{
  books = LMSBookLocalServiceUtil.getLMSBooskByCompanyIdGroupId(td.getCompanyId(), td.getScopeGroupId());
}	
    PortletURL iteratorURL = renderResponse.createRenderURL();
    iteratorURL.setParameter("jspPage",MyLibraryConstants.SHOW_LIST);
    PortletURL bookDetailsURL = renderResponse.createRenderURL();
	bookDetailsURL.setParameter("jspPage", MyLibraryConstants.PAGE_DETAILS);
	bookDetailsURL.setParameter("backURL", td.getURLCurrent());
%>
<br/><a href="<portlet:renderURL/>">&laquo; Go Back </a>
<h2>List of Books in Library</h2>
<br />
<liferay-ui:search-container  delta="4" emptyResultsMessage="sorry there are no books to diaplay" iteratorURL="<%= iteratorURL %>">
<liferay-ui:search-container-results total="<%=books.size()%>" results="<%=ListUtil.subList(books, searchContainer.getStart(), searchContainer.getEnd()) %>"/>
<liferay-ui:search-container-row modelVar="book" className="LMSBook">
<% bookDetailsURL.setParameter("bookId", Long.toString(book.getBookId())); %>
<liferay-ui:search-container-column-text name="Book Title" property="bookTitle" href="<%= bookDetailsURL.toString() %>"/>
<liferay-ui:search-container-column-text name="Author" property="author"/>
<liferay-ui:search-container-column-text name="Date Added" property="createDate"/>

<liferay-ui:search-container-column-jsp name="Actions" path="<%=MyLibraryConstants.ACTIONS_BOOK %>"/>
</liferay-ui:search-container-row>

<liferay-ui:search-iterator searchContainer="<%=searchContainer%>"/>
</liferay-ui:search-container>
